package com.learning.spring.security.base.config;

import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.rememberme.InMemoryTokenRepositoryImpl;

/**
 * ClassName: RememberMeConfiguration
 * Description:
 * Date: 2022/7/4 16:46
 *
 * @author Sam
 * @version V1.0.0
 */
public class RememberMeConfiguration {

    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        http.rememberMe(rememberMe ->
                rememberMe.tokenValiditySeconds(300)
                        .key("AppKey")
                        .useSecureCookie(true)
                        .alwaysRemember(true)
                        .tokenRepository(new InMemoryTokenRepositoryImpl())

        );
        return http.build();
    }
}
